﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>希顶字母数字</title>

    <link rel="stylesheet" type="text/css" href="./main.css" />
    <style>
        .button {
            background-color: #4CAF50;
            border: none;
            color: white;
            padding: 2px 32px;
            text-align: center;
            text-decoration: none;
            display: inline-block;
            font-size: 13px;
            margin: 4px 2px;
            -webkit-transition-duration: 0.4s; /* Safari */
            transition-duration: 0.4s;
            cursor: pointer;
        }

        .button1 {
            background-color: white;
            color: #88a1a1;
            border: 2px solid #B4F0FA;
        }

            .button1:hover {
                background-color: #A6E7F4;
                color: white;
            }

        .button2 {
            background-color: white;
            color: #88a1a1;
            border: 2px solid #FDECDB;
        }

            .button2:hover {
                background-color: #FACCB8;
                color: white;
            }
    </style>
    <script type="text/javascript">
        var datas = new Array();//字母数字表
        datas[0] = "bpmwjqxyn";
        datas[1] = "zDsrHNldt";
        datas[2] = "gkh45vF7B";
        datas[3] = "cfuaoeEAY";
        datas[4] = "L62T83V1i";
        function arabic2xdi8() {
            var input = document.getElementById('value').value;
            var output = "";
            var headlenth = input.length;
            for (var i = 0; i < input.length; i++)//获取小数点位置
            {
                if (input.charAt(i) == '.')
                    headlenth = i;
            }
            for (var i = 0; i < headlenth; i++)//打印小数点前
            {
                var place = (headlenth - i - 1) % 5;
                if (input.charAt(i) != 0)
                    output = output + datas[place].charAt(input.charAt(i) - 1);
                if (place == 0 && i != headlenth - 1)
                    output = output + "\'";
            }
            if(input.charAt(headlenth - 1) == 0)
            {
                output = output + "\'";
            }
            if (headlenth != input.length)//打印小数点
                output = output + ".";
            for (var i = headlenth + 1; i < input.length; i++)//打印小数点后
            {
                var place = (i - headlenth - 1) % 5;
                if (place == 0 && i != headlenth + 1)
                    output = output + "\'";
                if (input.charAt(i) != 0)
                    output = output + datas[place].charAt(input.charAt(i) - 1);
            }
            document.getElementById('t').value = output;
        }
        function glyphy2num(inp) {
            for (var i = 0; i < 5; i++)//获取小数点位置
            {
                for (var j = 1; j < 10; j++) {
                    if (inp == datas[i].charAt(j - 1)) {
                        return j * Math.pow(10, i);
                    }
                }
            }
        }
        function glyphy2num_(inp) {
            for (var i = 0; i < 5; i++)//获取小数点位置
            {
                for (var j = 1; j < 10; j++) {
                    if (inp == datas[i].charAt(j - 1)) {
                        return j * Math.pow(10, 4 - i);
                    }
                }
            }
        }
        function xdi82arabic() {
            var input = document.getElementById('value').value;
            var output = "";
            var headlenth = input.length;
            for (var i = 0; i < input.length; i++)//获取小数点位置
            {
                if (input.charAt(i) == '.')
                    headlenth = i;
            }
            var inpnum = 0;
            for (var i = 0; i <= headlenth; i++)//打印小数点前
            {
                if (input.charAt(i) == '\'' || input.charAt(i) == '.' || i == headlenth) {
                    var charinpnum = inpnum + "";
                    for (; charinpnum.length < 5 && input.charAt(i) != '.' && i > 5;) {
                        charinpnum = "0" + charinpnum;
                    }
                    output = output + charinpnum;
                    inpnum = 0;
                }
                else
                    inpnum += glyphy2num(input.charAt(i));
            }
            if (headlenth != input.length)//打印小数点
                output = output + ".";
            for (var i = headlenth + 1; i <= input.length; i++)//打印小数点后
            {
                if (input.charAt(i) == '\'' || i == input.length) {
                    var charinpnum = inpnum + "";
                    var charinpnum_ = "";
                    for (var j = charinpnum.length - 1; j >= 0; j--) {//倒置
                        charinpnum_ = charinpnum_ + charinpnum.charAt(j);
                    }
                    for (; charinpnum_.length < 5 && input.charAt(i) != '.' && i != input.length;) {
                        charinpnum_ = charinpnum_ + "0";
                    }
                    output = output + charinpnum_;
                    inpnum = 0;
                }
                else
                    inpnum += glyphy2num(input.charAt(i));
            }

            document.getElementById('t').value = output;
        }
    </script>

    <div id="navi" style="text-align: center">
        <big>雨音酱的希顶project（x</big>
    </div>
    <div id="main">
        <div id="main_content">
            <big><big>希顶字母数字转换器</big></big>
        </div>

        <div id="main_content">
            <div class="containter">
                <div class="row">
                    <div class="md-col-12">
                        输入数字<input type="text" size="70" id="value" placeholder="要获取的输入的值" />
                        <br>
                        <button class="button button1" onclick="arabic2xdi8()">
                            阿拉伯数字转字母数字
                        </button>
                        <button class="button button2" onclick="xdi82arabic()">
                            字母数字转阿拉伯数字
                        </button>
                        <br>
                        转换结果<input type="text" size="70" id="t" value="" />
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div id="footer">
        by 雨音境（隔夜柠檬茶，浅夏青柠，雨音浅夏）
        <a target="_blank" href="https://www.zhihu.com/people/qian-xia-qing-ning-17">知乎</a>
        <a target="_blank" href="https://web.archive.org/web/20201127030647/http://x-y.studio/">小时候的官网（存于互联网档案馆）</a>
    </div>
</html>
